import request from '@/utils/request'

export function tree(data) {
  return request({
    url: '/menu/tree',
    method: 'get',
    data
  })
}

export function treeByRole(data) {
  return request({
    url: `/menu/treeByRole/${data}`,
    method: 'get',
  })
}

export function create(data) {
  return request({
    url: `/menu`,
    method: 'post',
    data: data
  })
}

export function update(data) {
  return request({
    url: `/menu`,
    method: 'put',
    data: data
  })
}

export function remove(data) {
  return request({
    url: `/menu/${data}`,
    method: 'delete',
  })
}

export function listMenuIdByRole(data) {
  return request({
    url: `/menu/listMenuIdByRole/${data}`,
    method: 'get',
  })
}

export function createRole2Menu(roleId, menus) {
  return request({
    url: `/menu/createRole2Menu/${roleId}`,
    method: 'post',
    data: menus
  })
}
